@layout("/common/_curd/_container.html"){
<style>
	.input{
		height:100px;
		margin-bottom: 20px;
		line-height: 30px;
		margin-left: 20px;
	}
</style>
<script type="text/javascript">
	var ctx = "${basePath}";
	var grid_selector = "#grid-table";
	var pager_selector = "#grid-pager";
	
	$(function(){
		initGrid();
		initMenuBtn("btns", "${code}");
	});
	
	function initGrid(){
		var grid_url = ctx + "/${code}/list";
		var _colnames = ["主键",
//			"商品名称",
//			"供应商名称",
//			"生产厂家",
						"进货单编号",
						"进货日期", 
						"生产日期", 
						"保质期", 
						"单位",
						"仓库位置"];
		var _colmodel = [{name:"id", index:"id",hidden:true, width:100},
//			{name:"pname", index:"pname",hidden:true, width:100},
//			{name:"sname", index:"sname",hidden:true, width:100},
//			{name:"pfac", index:"pfac",hidden:true, width:100},
						{name:"b_code", index:"b_code",hidden:true, width:100},
						{name:"in_date", index:"in_date", width:100},
						{name:"made_date", index:"made_date", width:100},
						{name:"life", index:"life", width:100},
						{name:"danwei", index:"danwei", width:100,formatter:function () {
							return "日";
						}},
						{name:"where", index:"where", width:100}];
		
		jQuery(grid_selector).jqGrid({
			url : grid_url,
		    shrinkToFit : true,
			colNames : _colnames,
			colModel : _colmodel, 
			jsonReader : {id :"id"},
			pager : pager_selector,
			postData : {sort : "id", order : "desc"}
		});
	}
</script>


	<!-- 配置 grid -->
	<div class="row">
		<div class="col-xs-12 tb-grid">

			<div class="input">
				<span>请扫描商品二维码</span>
				<input id="code">
			</div>
			<!-- 按钮 -->
			<!--<div class="welljq well-sm" id="btns"></div>-->
			<!-- grid -->
			<table id="grid-table"></table>
			<!-- 分页-->
			<div id="grid-pager"></div>
		</div>
	</div>
	
	<!-- 引入所需的js -->
	@include("/common/_listscript.html"){}
	<script>
		$(function(){
			$('#code').focus();
			$('#code').bind('keypress',function(event){
				if(event.keyCode == "13"){
					ajaxData = {code:$('#code').val()};
					$.post("/putin/save",ajaxData,function (res) {
						console.log(res)
						if(res["success"]){
							layer.msg("操作成功！", {shift: -1,time:200,end:function () {
								jQuery("#grid-table").trigger("reloadGrid");
							}});
						}else{
							layer.msg("入库失败，请检查采购单内是否有该商品")
						}
					});
				}
			});
		});
	</script>
@}	